package com.eee.xiang.market.controller;

import com.eee.xiang.market.beans.OperateResponse;
import com.eee.xiang.market.beans.TNotice;
import com.eee.xiang.market.beans.TNoticeComment;
import com.eee.xiang.market.service.INoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/notice")
public class NoticeManagerController {


    @Autowired
    private INoticeService noticeService;

    @RequestMapping("/saveNotice")
    @ResponseBody
    OperateResponse saveNotice(TNotice notice){
        return noticeService.saveNotice(notice);
    }


    @RequestMapping("/noticeDetail")
    String noticeDetail(ModelMap map, String noticId){
        map.addAttribute("notice", noticeService.selectNotice(noticId));
        map.addAttribute("comentList", noticeService.selectNoticeCommentList(noticId));
        map.addAttribute("noticeId", noticId);
        return "noticeManager/noticeDetail";
    }

    @RequestMapping("/saveNoticeComment")
    @ResponseBody
    OperateResponse saveNoticeComment(TNoticeComment noticeComment){
        return noticeService.saveNoticeComment(noticeComment);
    }

}
